/**
 * Copyright (c) 2024 Hunan OpenValley Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef OHOS_OPENGLUTILS_H
#define OHOS_OPENGLUTILS_H

#include "types.h"
#include <GLES3/gl32.h>
#include <multimedia/image_framework/image_pixel_map_mdk.h>
#include <string>

class OpenGlUtils {
public:
    static GLuint NO_TEXTURE;
    static GLuint NO_FBO;
    static int loadTexture(OhosPixelMapInfos *pixelMap, int usedTexId);
    static int loadTexture(OhosPixelMapInfos *pixelMap, int usedTexId,
                           bool recycle);
    static int loadTexture(void *data, int width, int height, int usedTexId);
    static int loadShader(const std::string &strSource, const int iType);
    static int loadProgram(const std::string &strVSource,
                           const std::string &strFSource);
    static void texImage2D(int target, int level, OhosPixelMapInfos *pixelMap,
                           int border);
    static void texSubImage2D(int target, int level, int xoffset, int yoffset,
                              OhosPixelMapInfos *pixelMap);
    static void orthoMatrix(float *m, int mOffset, float left, float right,
                            float bottom, float top, float near, float far);
    static void setIdentityMatrix(float *sm, int smOffset);
    static std::string getEglErrorString();
    static void ConvertRGBAtoBGRA(void *rgbaBuffer, size_t numPixels);
    static void SaveRaw(const std::string &path, uint32_t frameid,
                        unsigned char *rgbbuf, int width, int height);
};

#endif // OHOS_OPENGLUTILS_H
